package mya.mes.mdc.logic.status.filter;


import mya.mes.mdc.logic.tag.PlcTagCache;
import mya.mes.mdc.share.plc.PlcTagVoFilter;
import mya.mes.mdc.share.vo.plc.MdcStatusTypeArray;
import mya.mes.mdc.share.vo.plc.PlcTagVo;

import java.util.ArrayList;
import java.util.List;

public class StatusFilter implements PlcTagVoFilter {

    @Override
    public List<PlcTagVo> filter(List<PlcTagVo> voList) {

        if (voList == null) {
            return null;
        }
        List<PlcTagVo> statusList = new ArrayList<>(voList.size());


        for (PlcTagVo vo : voList) {

            MdcStatusTypeArray mdcStatusTypeArray = PlcTagCache.getInstance().getMdcStatusType(vo);

            if (mdcStatusTypeArray == null) {
                continue;
            }
            vo.mdcStatusTypeArray = mdcStatusTypeArray;

            if (statusList == null) {
                statusList = new ArrayList<>();
            }

            statusList.add(vo);


        }

        return statusList;
    }


}
